<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .one {
            font-size: larger;
            color: blueviolet;
        }
    </style>
</head>
<body>
    <!-- 处理get和post的请求 -->
    <script src="https://code.jquery.com/jquery-3.6.1.min.js"></script>
    <div class = "one"></div>
    <button id = "doGet">doGet</button>
    <button id = "doPost">doPost</button>
    <button id = "doput">doPut</button>
    <button id = "doDelete">doDelete</button>
    <script>
        let div1 = document.querySelector('#doGet');
        div1.onclick = function() {
            /* 构造Ajax请求 */
            $.ajax({
                type: 'get',
                url: 'hello',
                success: function(body){
                   let toGet = document.querySelector('.one');
                   toGet.innerHTML = body;
                }
            });
        }

        let div2 = document.querySelector('#doPost');
        div2.onclick = function() {
            /* 构造Ajax请求 */
            $.ajax({
                type: 'post',
                url: 'hello',
                success: function(body){
                   let toGet = document.querySelector('.one');
                   toGet.innerHTML = body;
                }
            });
        }

        let div3 = document.querySelector('#doput');
        div3.onclick = function() {
            /* 构造Ajax请求 */
            $.ajax({
                type: 'put',
                url: 'hello',
                success: function(body){
                   let toGet = document.querySelector('.one');
                   toGet.innerHTML = body;
                }
            });
        }

        let div4 = document.querySelector('#doDelete');
        div4.onclick = function() {
            /* 构造Ajax请求 */
            $.ajax({
                type: 'delete',
                url: 'hello',
                success: function(body){
                   let toGet = document.querySelector('.one');
                   toGet.innerHTML = body;
                }
            });
        }

    </script>

</body>
</html>